package p2Exceptions;

/**
 * ExceptMain2 - Examples of run time errors that result in exceptions and how to catch them
 * 
 * @author tony
 *
 */
public class ExceptMain2 {
	public static void main(String[] args) {
		double dx = 0;
		System.out.println(" dx is " + dx );
		double dy = 0;
		dy = 1/dx;
		System.out.println(" dy is " + dy );

		int x = 0;
		System.out.println(" x is " + x );
		int y = 0;
		try {
				y = 1/x;
		System.out.println(" y is " + y );
		} catch (ArithmeticException ae) {
			System.err.println( "Arithmetic Exception detected");
		}
		
		String s = null;
		System.out.println(" s is " + s );
		
		try {
		System.out.println("  and it's length is " + s.length() );
		} catch (NullPointerException ne){
			System.err.println( "Null Pointer Dereference Exception detected");
		}	
	}
}
